package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;

import java.util.Arrays;

/**
 * 开机
 * 用于开机，并开启制水功能。必须绑定套餐后操作，否则无响应。
 * 接收应答一致：
 *
 */
public class StartUpMessage extends ProtocolMessage {

    /** 标记0x00 */
    private byte state;

    public byte getState() {
        return state;
    }

    public void setState(byte state) {
        this.state = state;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeByte(this.state);
    }

    @Override
    public void onDeserialize() {
        this.state = this.byteArray.readByte();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("StartUpMessage{");
        sb.append("state=").append(state);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
